<?php
class ApiTools
{
    const APP_ID = 'icode2023';

    /**
     * 签名验证
     */
    public static function checkSignature(array $params)
    {
        if(!$params) return false;

        $clientSign = $params['signature'];
        $array = [];
        $array['appid'] = self::APP_ID;
        $array['timestamp'] = $params['timestamp'];
        $array['nonce'] = $params['nonce'];
        ksort($array);
        $str = "";
        foreach ($array as $k => $v) {
            $str .= $k.$v;
        }
        $reserverSign = strtoupper(md5($str));
        return $clientSign == $reserverSign;
    }

 
}